package com.dog.gateway.receiver;

import com.alibaba.fastjson2.JSON;
import com.dog.framework.redis.config.RedisMessageReceiver;
import com.dog.framework.redis.dto.MessageDTO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.io.IOException;

/**
 * @author liuxk
 * @date 2024/1/15 11:12
 *
 */
@Slf4j
@Component
public class GatewayRedisMessageReceiver implements RedisMessageReceiver {

    @Override
    public void onMessage(String message) throws IOException, ClassNotFoundException {
        String newMessage = message.substring(1, message.length() - 1).replaceAll("\\\\","");
        log.info("MessageDTO is newMessage : {} ",newMessage);
        MessageDTO messageDTO1  =  JSON.parseObject(newMessage, MessageDTO.class);
        System.out.println(messageDTO1.getType());
    }
}
